package com.example.fbsmobile;

import com.example.fbsmobile.Booking;
import com.example.fbsmobile.util.SessionInfo;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

public class BookingStatus {
	public BookingStatus(){}
	public List<Booking> getBookingStatus() {
    	List<Booking> list = new ArrayList<Booking>();
    	try {
    		SessionInfo s = new SessionInfo();
    		URI uri = new URI("http://10.10.6.20:8080/FBS.Team7/BookingStatusServlet?id=" + s.getUserId());
    		HttpGet httpget = new HttpGet(uri);
			HttpResponse response = new DefaultHttpClient().execute(httpget);
			InputStream inp = response.getEntity().getContent();
			BufferedReader rd = new BufferedReader(new InputStreamReader(inp));
			String line;
			while ((line = rd.readLine()) != null) {
				String l1 = rd.readLine();
				String l2 = rd.readLine();
				String l3 = rd.readLine();
				String l4 = rd.readLine();
				String l5 = rd.readLine();
				String l6 = rd.readLine();
				String l7 = rd.readLine();
				String l8 = rd.readLine();
				String l9 = rd.readLine();
				list.add(new Booking(line, l1, l2, l3, l4, l5, l6, l7, l8, l9));
			}
    	} catch (Exception e) {
    	   e.printStackTrace();
    	}
    	return(list);
    }
	
}
